package Lee_code;

public class Lee_189 {

    public void reverse(int[] nums, int start, int end) {
        for(int i = start, j = end; i < j; i++, j--) {
            int temp = nums[i];
            nums[i] = nums[j];
            nums[j] = temp;
        }
    }

    public void rotate(int[] nums, int k) {

        int len = nums.length;
        int start = len - k;

        k = k % len;

        if(len<=1) {
            return;
        }

        reverse(nums, 0, len - 1);
        reverse(nums, 0, k-1);
        reverse(nums, k, len - 1);
    }
}
